package cloud.banson.emojilizer.network

import okhttp3.MultipartBody
import retrofit2.Response
import retrofit2.Retrofit
import retrofit2.converter.scalars.ScalarsConverterFactory
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.Part

// const val MOCK_URL = "https://xzcxzc.free.beeceptor.com"

/**
* The code starts by creating a NetworkApiService object.
* This is done with the Retrofit library, which is then passed to the NetworkApi class.
* The NetworkApi class creates an instance of this service.
 */

private val retrofit = Retrofit.Builder()
    .addConverterFactory(ScalarsConverterFactory.create())
    .baseUrl(BASE_URL)
    .build()

interface NetworkApiService {
    @Multipart
    @POST("/get_result")
    suspend fun uploadImage(
        @Part file: MultipartBody.Part
    ): Response<String?>
}

object NetworkApi {
    val retrofitService: NetworkApiService by lazy {
        retrofit.create(NetworkApiService::class.java)
    }
}